package programs.statement;

import programs.expression.implementedClasses.Variable;
import programs.expression.superClasses.Expression;
import programs.expression.superClasses.ExpressionType;

public class Turn extends Action {

	private Expression amountToTurn;

	public Turn(Expression amountToTurn) {
		this.amountToTurn = amountToTurn;
	}

	@Override
	public void execute() {
			getExecuter().turn((Double) getAmountToTurn().getValue());
	}

	@Override
	public boolean isValidStatement() {
		return getAmountToTurn().isValidExpression() && (getAmountToTurn().getReturnType() == ExpressionType.DOUBLE);
	}
	
	public Expression getAmountToTurn() {
		return this.amountToTurn;
	}

	@Override
	public void assignGlobalVariable(Variable variable) {
		amountToTurn = getAmountToTurn().assignGlobalVariable(variable);
	}
}
